package com.sum.tea.xinlian.bean

import android.os.PowerManager

class AndroidWakeLock(private val powerManager: PowerManager) {
    private var wakeLock: PowerManager.WakeLock? = null

    fun acquireWakeLock() {
        if (wakeLock == null) {
            wakeLock = powerManager.newWakeLock(
                PowerManager.PARTIAL_WAKE_LOCK,
                "YourApp::WakeLockTag"
            )
        }
        wakeLock?.acquire()
    }

    fun releaseWakeLock() {
        wakeLock?.let {
            if (it.isHeld) {
                it.release()
            }
        }
    }
}
